﻿<%@ Page Language="C#"  MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="staticReports.aspx.cs" Inherits="NCC_SOP.staticReports" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
.label
{
    width:200px;
}

.option
{
    width:300px;
}
    
</style>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <fieldset>
        <legend>Searching Criteria:</legend>
        <div style="float: left; width: 100%;">
            <telerik:radgrid id="staticReportList" runat="server" width="100%" datasourceid="SqlDataSource1"
                allowfilteringbycolumn="True" allowsorting="True" allowpaging="True" pagesize="7" Skin="WebBlue"
                autogeneratecolumns="False" onprerender="RadGrid1_PreRender" showstatusbar="true"
                enablelinqexpressions="false">
                <PagerStyle Mode="NextPrevNumericAndAdvanced" Position="Bottom"></PagerStyle>

          <MasterTableView DataKeyNames="rptID" AutoGenerateColumns="false" AllowFilteringByColumn="True" ShowFooter="True">
              <Columns>
                  <telerik:GridBoundColumn UniqueName="rptName" DataField="rptName" HeaderText="Report Name"
                      AutoPostBackOnFilter="true" AllowFiltering="false" HeaderStyle-Width="100px" />

                  <telerik:GridBoundColumn UniqueName="datasource" DataField="datasource" HeaderText="Data Source"
                      AutoPostBackOnFilter="true" HeaderStyle-Width="150px">
                      <FilterTemplate>
                          <telerik:RadComboBox ID="RadComboBoxDS" DataSourceID="SqlDataSource2" DataTextField="datasource"
                              DataValueField="datasource" Height="200px" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("datasource").CurrentFilterValue %>'
                              runat="server" OnClientSelectedIndexChanged="DSIndexChanged">
                              <Items>
                                  <telerik:RadComboBoxItem Text="All" />
                              </Items>
                          </telerik:RadComboBox>
                          <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
                              <script type="text/javascript">
                                  function DSIndexChanged(sender, args) {
                                      var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                      tableView.filter("datasource", args.get_item().get_value(), "EqualTo");
                                  }
                              </script>
                          </telerik:RadScriptBlock>
                      </FilterTemplate>
                  </telerik:GridBoundColumn>


                  <telerik:GridBoundColumn UniqueName="dataType" DataField="dataType" HeaderText="Report Type"
                      HeaderStyle-Width="150px">
                      <FilterTemplate>
                          <telerik:RadComboBox ID="RadComboBoxType" DataSourceID="SqlDataSource3" DataTextField="dataType"
                              DataValueField="dataType" Height="200px" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("dataType").CurrentFilterValue %>'
                              runat="server" OnClientSelectedIndexChanged="TypeIndexChanged">
                              <Items>
                                  <telerik:RadComboBoxItem Text="All" />
                              </Items>
                          </telerik:RadComboBox>
                          <telerik:RadScriptBlock ID="RadScriptBlock2" runat="server">
                              <script type="text/javascript">
                                  function TypeIndexChanged(sender, args) {
                                      var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                      tableView.filter("dataType", args.get_item().get_value(), "EqualTo");
                                  } 
                              </script>
                          </telerik:RadScriptBlock>
                      </FilterTemplate>
                  </telerik:GridBoundColumn>



                  <telerik:GridBoundColumn UniqueName="rptDescription" DataField="rptDescription" HeaderText="Report Description"
                      AllowFiltering="false" HeaderStyle-Width="200px" />

                  <telerik:GridBoundColumn  DataField="status" HeaderText="Status" UniqueName="status"
                      AllowFiltering="false" CurrentFilterFunction="Contains">
                  </telerik:GridBoundColumn>
                           
                  <telerik:GridDateTimeColumn DataField="updatedOn" HeaderText="Updated On" UniqueName="updatedOn"
                      AllowFiltering="false" SortExpression="updatedOn" DataFormatString="{0:MM/dd/yyyy}">
                  </telerik:GridDateTimeColumn>


                  
                  <telerik:GridTemplateColumn 
                    UniqueName="edit" 
                    AllowFiltering="false" 
                    HeaderText="VIEW" HeaderStyle-Width="50px">
                    
                   <ItemTemplate>
                         <%#Eval("isRPT").ToString().Equals("0") ?
                                                         "<a href='pdfViewer.aspx?rptID=" + Eval("rptID").ToString().Trim() + "'><img src='images/file_view.jpg' width='20px' height='20px' alt='' /></a>" :
                                                         "<a href='" + Eval("fileName").ToString().Trim() + "?rptID=" + Eval("rptID").ToString().Trim() + "'><img src='images/file_view.jpg' width='20px' height='20px' alt='' /><img src='images/Dynamic_Icon.png' width='20px' height='20px' alt='' /></a>"
                         %>
                    </ItemTemplate>


                </telerik:GridTemplateColumn>


              </Columns>
          </MasterTableView>
          <ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="true">
                <Selecting AllowRowSelect="true" EnableDragToSelectRows="false" />
          </ClientSettings>
      </telerik:radgrid>
        </div>
    </fieldset>


		     <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:localSQLString %>"
            ProviderName="System.Data.SqlClient" 
            ></asp:SqlDataSource>


  <asp:SqlDataSource ID="SqlDataSource2"  runat="server" ConnectionString="<%$ ConnectionStrings:localSQLString %>"
            ProviderName="System.Data.SqlClient" 
            SelectCommand="select distinct dataSource from metaDisplayView"

            ></asp:SqlDataSource>

  <asp:SqlDataSource ID="SqlDataSource3"  runat="server" ConnectionString="<%$ ConnectionStrings:localSQLString %>"
            ProviderName="System.Data.SqlClient" 
            SelectCommand="select distinct dataType from metaDisplayView "
            ></asp:SqlDataSource>

   <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:localSQLString %>"
            ProviderName="System.Data.SqlClient"
            SelectCommand="SELECT a.userID, b.reportID, b.departmentID FROM dbo.staffDepartmentMapping a INNER JOIN dbo.reportDepartmentMapping B ON a.departmentID=b.departmentID"
            ></asp:SqlDataSource>

</asp:Content>